package org.hbhk.aili.job.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.dangdang.ddframe.job.executor.AbstractElasticJobExecutor;
import com.dangdang.ddframe.job.executor.handler.ExecutorServiceHandler;
import com.dangdang.ddframe.job.executor.handler.JobExceptionHandler;
import com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler;
import com.dangdang.ddframe.job.executor.handler.impl.DefaultJobExceptionHandler;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface JobConfig {
	/**
	 * Job 名称
	 * 
	 * @see com.dangdang.ddframe.job.config.JobCoreConfiguration#jobName
	 * @return job名称, string
	 */
	String name();

	/**
	 * Job cron表达式
	 * 
	 * @see com.dangdang.ddframe.job.config.JobCoreConfiguration#cron
	 * @return cron表达式, string
	 */
	String cron();

	/**
	 * Job 描述
	 * 
	 * @return string
	 */
	String description() default "";

	/**
	 * 分片数量
	 * 
	 * @see com.dangdang.ddframe.job.config.JobCoreConfiguration#shardingTotalCount
	 * @return 分片数量,String
	 */
	int shardingCount() default 1;

	/**
	 * 分片参数
	 * 
	 * @see com.dangdang.ddframe.job.config.JobCoreConfiguration#shardingItemParameters
	 * @return 分片参数,String
	 */
	String shardingItemParameters() default "";

	/**
	 * 失效转移
	 * 
	 * @see com.dangdang.ddframe.job.config.JobCoreConfiguration#failover
	 * @return true or false str
	 */
	boolean failover() default true;

	/**
	 * 错过执行
	 * 
	 * @see com.dangdang.ddframe.job.config.JobCoreConfiguration#misfire
	 * @return true or false str
	 */
	boolean misfire() default false;

	/**
	 * Job 参数
	 * 
	 * @return Job参数,String
	 */
	String jobParameter() default "";

	/**
	 * 监控作业执行时状态
	 * 
	 * @see com.dangdang.ddframe.job.lite.config.LiteJobConfiguration#monitorExecution
	 * @return true or false str
	 */
	boolean monitorExecution() default true;

	/**
	 * 最大容忍的本机与注册中心的时间误差秒数.
	 * 
	 * @see com.dangdang.ddframe.job.lite.config.LiteJobConfiguration#maxTimeDiffSeconds
	 * @return int
	 */
	int maxTimeDiffSeconds() default -1;

	/**
	 * 作业辅助监控端口.
	 * 
	 * @see com.dangdang.ddframe.job.lite.config.LiteJobConfiguration#monitorPort
	 * @return int
	 */
	int monitorPort() default -1;

	/**
	 * 作业分片策略实现类全路径.
	 * 
	 * @see com.dangdang.ddframe.job.lite.config.LiteJobConfiguration#jobShardingStrategyClass
	 * @return string
	 */
	String jobShardingStrategyClass() default "";

	/**
	 * 作业是否启动时禁止.
	 * 
	 * @see com.dangdang.ddframe.job.lite.config.LiteJobConfiguration#disabled
	 * @return true of false str
	 */
	boolean disabled() default false;

	/**
	 * 本地配置是否可覆盖注册中心配置.
	 * 
	 * @see com.dangdang.ddframe.job.lite.config.LiteJobConfiguration#overwrite
	 * @return true of false str
	 */
	boolean overwrite() default false;

	/**
	 * 修复作业服务器不一致状态服务执行间隔分钟数.
	 * 
	 * @see com.dangdang.ddframe.job.lite.config.LiteJobConfiguration#reconcileIntervalMinutes
	 * @return int, defalut 10
	 */
	int reconcileIntervalMinutes() default 10;

	/**
	 * 是否流式处理, 适用于DataflowJobConfiguration
	 * 
	 * @see com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration
	 * @see com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration#streamingProcess
	 * @return true of false str
	 */
	boolean streamingProcess() default true;

	/**
	 * 命令脚本, 适用于ScriptJobConfiguration
	 * 
	 * @see com.dangdang.ddframe.job.config.script.ScriptJobConfiguration
	 * @see com.dangdang.ddframe.job.config.script.ScriptJobConfiguration#scriptCommandLine
	 * @return string
	 */
	String scriptCommandLine() default "";

	/**
	 * 异常处理类
	 * 
	 * @see JobExceptionHandler
	 * @see AbstractElasticJobExecutor#jobExceptionHandler
	 * @return JobExceptionHandler
	 */
	Class<? extends JobExceptionHandler> exceptionHandlerClass() default DefaultJobExceptionHandler.class;

	/**
	 * 线程池处理类，默认ExecutorServiceHandler, 同时处理数据的并发线程数不能小于1仅ThroughputDataFlow作业有效,
	 * 默认线程池大小：CPU核数*2
	 * 
	 * @see ExecutorServiceHandler
	 * @see AbstractElasticJobExecutor#executorServiceHandler
	 * @return ExecutorServiceHandler
	 */
	Class<? extends ExecutorServiceHandler> executorServiceHandlerClass() default DefaultExecutorServiceHandler.class;

}
